<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="标题" prop="title">
        <el-input
          v-model="queryParams.title"
          placeholder="请输入标题"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>



    <div class="cont" >
      <div @click="skipDetails(item)" class="cont-invitation" v-for="item in historyList">
        <!--用户名和时间-->
        <div style="display: flex;height: 60px; flex-direction: row; margin: 10px 10px 5px 10px ">
          <img :src="item.avatar" :width="35" :height="35" style="border-radius: 50%;margin: 10px 0 0 20px">
          <!--          用户名-->
          <h3 style="margin-left: 12px;color: #2c3e50">
            {{item.nickName}}
          </h3>
          <div style="margin: 27px 0 0 10px;color: #97a8be;font-size: 10px">

            {{item.inviCreatTime}}
          </div>
        </div>
        <!--      内容-->
        <div style="margin: 0px 20px 5px 20px">
          <div style="font-size: 25px;font-weight: 600">
            {{item.title}}
          </div>
          <div style="font-size: 18px; margin: 0" v-html="item.content">
          </div>
        </div>
        <div style="display: flex;">
          <div v-for="(img) in item.imgUrlList" style="margin: 0px 10px 10px 15px">
            <img :src="img" :width="100" :height="100">

          </div>
        </div>


      </div>
    </div>


  </div>
</template>

<script>
import { listHistory, getHistory, delHistory, addHistory, updateHistory } from "@/api/petSys/history";

export default {
  name: "History",
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 浏览记录表格数据
      historyList: [],
      // 弹出层标题
      title: "",

      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        inviId: null,
        browseTime: null,
        userId: null,
      },

    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询浏览记录列表 */
    getList() {
      this.loading = true;
      listHistory(this.queryParams).then(response => {
        console.log(response)
        this.historyList = response.rows;
        this.historyList.forEach(item=>{
          for (var i = 0; i < item.imgUrlList.length; i++) {
            item.imgUrlList[i] = item.imgUrlList[i].replace(/\\/g, "/")
            item.imgUrlList[i] = "/" + item.imgUrlList[i]
            console.log(item.imgUrlList[i])

          }


        })
        this.total = response.total;
        this.loading = false;
      });
    },


    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },




    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm('是否确认删除浏览记录编号为"' + ids + '"的数据项？').then(function() {
        return delHistory(ids);
      }).then(() => {
        this.getList();
        this.$modal.msgSuccess("删除成功");
      }).catch(() => {});
    },
    skipDetails(item){


      this.$router.push({
        path: '/invi/details',
        query: {
          id: item.id

        }
      })
    }
  }
};
</script>
<style>
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
}

.app-container {
  height: 100%;
}
.cont {
  height: 95%;
  overflow: auto;
}
section {
  height: 80%;
}
.cont-invitation{
  margin: 10px;
  background: #F9F9F9;
  border-bottom: 1px solid #E4E7EC;
  border-top: 1px solid #E4E7EC;
}
</style>
